<!--
 * @ Author: 舒克
 * @Official Accounts: 氧化1028
 * @ email: 143587623@qq.com
 * @github: https://gitee.com/KingSio
 * @Date: 2021-03-19 00:47:12
 * @LastEditTime: 2021-03-19 00:51:48
 * @FilePath: \一般用于源码\source-notes\源码记录\Promise和AsyncAwait\PromiseRace.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var a=new Promise((resolve,reject)=>{
            setTimeout(() => {
                resolve("成功1")
            }, 1000);
        })
        var b=new Promise((resolve,reject)=>{
            setTimeout(() => {
                resolve("成功2")
            }, 2000);
        })
        var arr=[a,b];
        var res=Promise.race(arr)
        console.log(res);
        res.then((res)=>{
            console.log(res);
        })
    </script>
</body>
</html>